package com.example.administrator.printoutindemo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;



import java.util.List;


public class StoreListOutStorageAdapter extends BaseAdapter {

	private Context mContext = null;
	private LayoutInflater mInflater = null;
	private Outstorage outstorage = null;

	private List<Outstorage> li_outstorage = null;

	private class ViewHolder {
		TextView txt_title;
	}

	private ViewHolder holder = null;

	public StoreListOutStorageAdapter(Context context) {
		// TODO Auto-generated constructor stub
		mContext = context;
	}

	public void setList(List<Outstorage> li_outstorage) {

		this.li_outstorage = li_outstorage;

		this.mInflater = (LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub

		int result = 0;
		if (null != li_outstorage) {
			result = li_outstorage.size();
		}
		return result;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		Object result = null;
		if (null != li_outstorage) {
			result = li_outstorage.get(position);
		}

		return result;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		int result = 0;
		if (null != li_outstorage) {
			result = li_outstorage.size();
		}
		return result;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null) {

			holder = new ViewHolder();

			convertView = mInflater.inflate(R.layout.store_adapter_listqrcode,
					null);

			holder.txt_title = (TextView) convertView
					.findViewById(R.id.txt_title);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		if (null != this.li_outstorage) {

			Outstorage c = li_outstorage.get(position);

			holder.txt_title.setText(c.get_out_storage_time() + ",出："
					+ c.get_out_storage_count().trim() + c.get_unit().trim() + ",接收人："
					+ c.get_receive_username().trim() + "\n地址："
					+ c.get_receive_address().trim());

		}

		return convertView;
	}

}